

layui.config({
    version:'1510164124181'
}).use(['form','laydate', 'laypage', 'layer', 'element'],function(){
    form = layui.form;
    layer = layui.layer;
    $ = layui.jquery;
    laydate = layui.laydate;//日期
    laypage = layui.laypage;//分页
    element = layui.element; //元素操作
    inituserdata();
});

function inituserdata(){
    $.ajax({
        url: httpurl+"/selectSysInfoList",
        cache: false,
        headers: {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Methods": "*",
            "Access-Control-Allow-Headers": "Authorization",
            "Authorization": GetTokenInfo()
        },
        contentType : 'application/json',
        data: {
            "page":pageNo,
            "pagesize":pageRecords,
        },
        success: function(data) {
            let dataInfo=data.data;
            let info="";
            if(data.rtnCode==200){
                if(dataInfo.length>0){
                    for(let i=0;i<dataInfo.length;i++) {
                        totalRecords = dataInfo[dataInfo.length - 1].total;
                        info += '<tr>' +
                            '<td><input type="checkbox" data-id="'+dataInfo[i].id+'" name="box" class="aceChild"/></td>' +
                            '<td>' + dataInfo[i].id + '</td>' +
                            '<td>' + dataInfo[i].name + '</td>' +
                            '<td>' + dataInfo[i].value + '</td>' +
                            '<td>' + dataInfo[i].identify + '</td>' +

                            '<td>' + (!isNotNull(dataInfo[i].note)?"":dataInfo[i].note) + '</td>' +
                            '<td>' +
                            '<a href="AddSysInfo.html?Id='+dataInfo[i].id+'">查看</a>&nbsp;&nbsp;&nbsp;' +
                            '<a href="#" data-id="'+dataInfo[i].id+'" data-info="deleteSysInfo" onclick="DeleteInfo(this);">删除</a>' +
                            '</td>' +
                            '</tr>';
                    }
                }else{
                    totalRecords =0;
                    info += '<tr>'
                        +'<td colspan="8" style="text-align:center;">暂无数据</td>'
                        +'</tr>';
                }
                $("#TableInfo tbody").html(info);
                page();
            }
        }

    });
}
//分页
function page(){
    laypage.render({
        elem: 'page' //注意，这里的 test1 是 ID，不用加 # 号
        ,count:totalRecords //数据总数，从服务端得到
        ,curr: pageNo //获取起始页 location.hash.replace('#!fenye=', '')
        ,hash: 'fenye' //自定义hash值
        ,layout: ['count', 'prev', 'page', 'next', 'skip']
        ,limit:10
        ,jump: function(obj, first){
            //首次不执行
            if(!first){
                //console.log("当前页==="+obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                //console.log("每页显示条数==="+obj.limit); //得到每页显示的条数
                pageNo = obj.curr;
                pageRecords=obj.limit;
                inituserdata();
            }
        }
    });
}

